--[[/**
-- * 
 * 伤害的[0]%转化为生命值
-- *
-- */]]

---@class BuffEffect216300 : BaseBuffEffect
BuffEffect216300 = ClientFight.CreateClass("BuffEffect216300", ClientFight.BaseBuffEffect)
local t = BuffEffect216300

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    if (not buff.target:isSummons())then
    return IBuffEffect.FAIL;
    end
    local summonsCreater = buff.target.summonsCreater;
    if (summonsCreater == nil) then
    return IBuffEffect.FAIL;
    end
    if (FighterStateEnum.is(summonsCreater,FighterStateEnum.BAN_HEAL))then
    return IBuffEffect.FAIL;
    end
    if (summonsCreater:isDie()) then
    return IBuffEffect.FAIL;
    end
    if (table.getn(parameters) < 3) then
        return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

    end
    if (not (parameters[3] )) then
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

    end
    local fightResult =  parameters[3];
    if (not AttackUtils.isDamage(fightResult.state)) then
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

    end
    if (not fightResult:isDamage()) then
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

    end
    local effectVal = buff.buffBean.f_BuffEffectValue;
    local damage = fightResult.damage;

    local addHp = (damage* Utils.toRatio(effectVal[1]));
    DamageManager.setFighterHp(fight, summonsCreater, buff.target, nil, DamageResultTypeEnum.HEAL,addHp,
    summonsCreater.hp + addHp, false, false, true);
    SkillRoleMgr.savePathFile( "[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
    .. buff.modelId .. " 伤害转换生命值给召唤物的主人:"..addHp);
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

end

t.New()